import React, {useEffect} from 'react';
import {Button, Card, Descriptions, Space} from "antd";
import {getHospitalShowAsync, useSelectorHospList} from "@/store/slice/hospList";
import {useAppDispatch} from "@/hooks";
import {useLocation, useNavigate, useParams} from "react-router-dom";
import {changeTitle, delPanesByKey} from "@/store/slice/common";

function Show() {
    const {id} = useParams()
    const navigate = useNavigate()
    const location = useLocation()
    const {showList} = useSelectorHospList()
    // console.log(showList)
    const dispatch = useAppDispatch()
    useEffect(()=>{
            dispatch(getHospitalShowAsync(id as string,location.pathname))
    },[])
if(showList.bookingRule){
        return (
            <Space direction={"vertical"}>
                <Button onClick={()=>{
                    dispatch(delPanesByKey(location.pathname))
                    navigate("/hospital/hospitalList")
                }} danger type={"primary"}>关闭返回</Button>
                <Card>
                    <Descriptions column={2} title="医院基本信息" bordered>
                        <Descriptions.Item label="医院名称">{showList.hospital.hosname}</Descriptions.Item>
                        <Descriptions.Item label="医院LOGO">
                            <img width={100} src={"data:image/jpeg;base64,"+showList.hospital.logoData}/>
                        </Descriptions.Item>
                        <Descriptions.Item label="医院编码">{showList.hospital.hoscode}</Descriptions.Item>
                        <Descriptions.Item label="医院地址">{showList.hospital.param.fullAddress}</Descriptions.Item>
                        <Descriptions.Item label="乘车路线" span={2}>{showList.hospital.route}</Descriptions.Item>
                        <Descriptions.Item label="医院简介" span={2}>{showList.hospital.intro}</Descriptions.Item>
                    </Descriptions>
                </Card>

                <Card>
                    <Descriptions column={2} title="医院预约规则信息" bordered>
                        <Descriptions.Item label="预约周期">{showList.bookingRule.cycle}</Descriptions.Item>
                        <Descriptions.Item label="放号时间">{showList.bookingRule.releaseTime}</Descriptions.Item>
                        <Descriptions.Item label="停号时间">{showList.bookingRule.stopTime}</Descriptions.Item>
                        <Descriptions.Item label="退号时间">{showList.bookingRule.quitTime}</Descriptions.Item>
                        <Descriptions.Item label="预约规则" span={2}>{showList.bookingRule.rule}</Descriptions.Item>
                    </Descriptions>
                </Card>
            </Space>
        );
    }else {
    return
        }
    }


export default Show;